package com.zx._03_并发.chapter_05_concurrent;

import java.util.TreeSet;
import java.util.concurrent.ConcurrentSkipListSet;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StopWatch;

/**
 * ConcurrentSkipListSet
 */
@Slf4j
public class Demo_03 {

    public static void main(String[] args) {
        StopWatch sw = new StopWatch();//计时器
        int total = 5000;
        ConcurrentSkipListSet<String> a = new ConcurrentSkipListSet<>();
        TreeSet<String> b = new TreeSet<>();

        sw.start("ConcurrentSkipListSet");
        for (int i = 0; i < total; i++) {
            a.add(String.valueOf(i));
        }
        sw.stop();

        sw.start("TreeSet");
        for (int i = 0; i < total; i++) {
            b.add(String.valueOf(i));
        }
        sw.stop();

        log.info(sw.prettyPrint());

        log.info("ConcurrentSkipListSet={}", a.toString());
        log.info("TreeSet={}", b.toString());
    }
}
